//
//  ChoosePileNOView.m
//  Runone
//
//  Created by ekkaLyn on 2017/3/14.
//  Copyright © 2017年 runone. All rights reserved.
//

#import "ChoosePileNOView.h"
#import "SDAutoLayout.h"

@interface ChoosePileNOView ()

@property (nonatomic, copy) NSString *leftTitleStr; //左边标题

@end

@implementation ChoosePileNOView

- (ChoosePileNOView *) initWithDefalutHeight:(CGFloat) height titleString:(NSString *)titleStr {
    _leftTitleStr = titleStr;
    return [self initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, height)];
}

//施工事件   其他事件 上报设置尺寸
-(instancetype)initWithFrame:(CGRect)frame {
    self=[super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor colorWithRed:226.0 / 255 green:230.0 / 255 blue:240.0 / 255 alpha:1]];
        
        [self configUI];
        [self layoutUI];
    }
    return self;
}
//设置UI
- (void) configUI {
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.font = [UIFont systemFontOfSize:15];
    _titleLabel.textAlignment = NSTextAlignmentRight;
    _titleLabel.text = _leftTitleStr;
    
    _midTextField = [[UITextField alloc] init];
    _midTextField.font            = [UIFont systemFontOfSize:15];
    _midTextField.backgroundColor = [UIColor whiteColor];
//    _midTextField.enabled         = NO;
    
    _verticalLineV = [[UIView alloc] init];
    _verticalLineV.backgroundColor = [UIColor blackColor];
    
    _rightTextField = [[UITextField alloc] init];
    _rightTextField.font            = [UIFont systemFontOfSize:15];
    _rightTextField.backgroundColor = [UIColor whiteColor];
//    _rightTextField.enabled         = NO;
    
    _lineView   = [UIView new];
    _lineView.backgroundColor = [UIColor whiteColor];
    [self sd_addSubviews:@[self.titleLabel, self.midTextField, self.rightTextField, self.lineView, self.verticalLineV]];
}

//- (void) setKLbel:(UITextField *)textField {
//    UILabel *kLabel = [[UILabel alloc] init];
//    kLabel.frame = CGRectMake(0, 0, 30, textField.height);
//    kLabel.text = @"K";
//    kLabel.textAlignment = NSTextAlignmentCenter;
//    kLabel.font = [UIFont systemFontOfSize:15];
//    kLabel.backgroundColor = [UIColor yellowColor];
//    
//    textField.leftView     = kLabel;
//    textField.leftViewMode = UITextFieldViewModeAlways;
//}

//加载UI
- (void) layoutUI {
    self.titleLabel.sd_layout
    .leftSpaceToView(self, 0)
    .topSpaceToView(self, 10)
    .heightIs(34)
    .widthIs(110)
    ;
    
    self.midTextField.sd_layout
    .leftSpaceToView(self.titleLabel, 8)
    .topSpaceToView(self, 8)
    .heightIs(34)
    .widthIs(([UIScreen mainScreen].bounds.size.width - 110 - 8 - 8 - 11) / 2)
    ;
    
    self.verticalLineV.sd_layout
    .leftSpaceToView(self.midTextField, 5)
    .rightSpaceToView(self.rightTextField,5)
    .topSpaceToView(self, 5)
    .widthIs(1)
    .heightIs(40);
    
    self.rightTextField.sd_layout
    .rightSpaceToView(self, 8)
    .topSpaceToView(self, 8)
    .heightIs(34)
    .widthIs(([UIScreen mainScreen].bounds.size.width - 110 - 8 - 8 - 11) / 2)
    ;
    
    self.lineView.sd_layout
    .leftSpaceToView(self, 8)
    .rightSpaceToView(self, 8)
    .heightIs(1)
    .topSpaceToView(self.titleLabel, 9)
    ;
    [self setupAutoHeightWithBottomView:self.lineView bottomMargin:0];
   // [self setKLbel:self.midTextField];

}

- (void) setMiddelString:(NSString *)midStr rightString:(NSString *)rightStr {
    self.midTextField.text   = midStr;
    self.rightTextField.text = rightStr;
}

@end
